package com.etc.controller;

import com.etc.pojo.User;
import com.etc.pojo.Video;
import com.etc.service.UserService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;


@Controller
@RequestMapping("/AdminController")
public class AdminController {
@Autowired
    UserService service;
    ModelAndView modelAndView = new ModelAndView();
    @RequestMapping("/getQueryAllUser")
    @ResponseBody
    public PageInfo<User> getQueryAllUser(@RequestParam(value = "pageNo",defaultValue = "1") Integer pageNo ,
                                          @RequestParam(value = "pageSize",defaultValue = "3") Integer pageSize){

    PageInfo<User> pageInfo=service.getQueryAllUser(pageNo,pageSize);
    return pageInfo;
}
    @ResponseBody
    @RequestMapping("/queryAllUsers")
    private List<User> queryAllUsers() {

        List<User> list = service.getQueryAllUsers();
        return list;
    }
    @ResponseBody
    @RequestMapping(value = "updateUser")
    public boolean updateUser(@RequestParam(value = "user")   User user) {
        boolean b = service.updateUser(user);
        return b;
    }
    @ResponseBody
    @RequestMapping(value = "deleteUser")
    public boolean deleteUser(@RequestParam(value = "userId")  String userId,@RequestParam("userState") int userState) {
        boolean b = service.getDeleteUser(userId,userState);
        return b;
    }

    @ResponseBody
    @RequestMapping(value = "queryUserByUserId")
    public User queryUserByUserId(@RequestParam(value = "userId")  String userId) {
        User user = service.getUserByUserId(userId);
        return user;
    }
}
